<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.welfare.admin.call.*" %>
<%

	HashList code007	= CommonUtil.getCodeList("007", "");	//행정동
	HashList code300	= CommonUtil.getCodeList("300");		//상담경로
	HashList code301	= CommonUtil.getCodeList("301");		//상담유형
	HashList code302	= CommonUtil.getCodeList("302");		//상담결과
	HashList code303	= CommonUtil.getCodeList("303", "");	//세대구분
	HashList code304	= CommonUtil.getCodeList("304", "");	//보장구분
	HashList code305	= CommonUtil.getCodeList("305");	//분류1
	HashList code306	= CommonUtil.getCodeList("306");	//분류2
	HashList code309	= CommonUtil.getCodeList("309");	//알림요청


	String counsel_id		= StringUtil.nvl(request.getParameter("counsel_id"));


	HashMap infos = new HashMap();
	infos.put("counsel_id",	counsel_id);


	CallDAO dao 		= new CallDAO();
	HashList info		= dao.selectCounselInfo(infos);		



%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= SYSTEM_NAME %></title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>

	<script type="text/javascript">
	
	
	$(document).ready(function() {
		$('#counsel_date').mask('9999.99.99').datepicker();
		
		//분류1 변경시 해당 분류2 조회
		$('.counsel_kind').on('change', function() {
			cfLoadCounselPart($(this), $(this).closest('td').find('.counsel_part'), '');
		});
		
		cfLoadCounselPart($(document.saveForm.counsel_kind1), $(document.saveForm.counsel_part1), "<%= info.get("counsel_part1",0) %>");
		if ("<%= info.get("counsel_kind2",0) %>" != "") {
			cfLoadCounselPart($(document.saveForm.counsel_kind2), $(document.saveForm.counsel_part2), "<%= info.get("counsel_part2",0) %>");
		}
		if ("<%= info.get("counsel_kind3",0) %>" != "") {
			cfLoadCounselPart($(document.saveForm.counsel_kind3), $(document.saveForm.counsel_part3), "<%= info.get("counsel_part3",0) %>");
		}
	});

	
	function fnSave() {
		if (cfCheckRequired(document.saveForm.counsel_date, '상담일자를 선택하세요')
				&& cfCheckRequired(document.saveForm.counsel_path, '상담경로를 선택하세요')
				&& cfCheckRequired(document.saveForm.counsel_type, '상담유형을 선택하세요')
				&& cfCheckRequired(document.saveForm.counsel_kind1, '분류1을 선택하세요')
				&& cfCheckRequired(document.saveForm.counsel_part1, '분류2을 선택하세요')
				&& cfCheckRequired(document.saveForm.counsel_result, '처리결과를 선택하세요')
		) {
			if (confirm(MSG_U)) {
				$.ajax({
					url: './counselSave.do',
					type: "POST",
				    dataType: 'json',//html,text,json
				    data: $('#saveForm').serialize(),
				    error: function(data, status, err){
				    	alert(err);
				    },
					success: function(data){
						if (data.result_code == 'SESSION_TIMEOUT') {
							alert("오랜시간 사용하지 않아 로그아웃되었습니다.\n로그인화면으로 이동합니다.");
							self.close();
							opener.top.location.href = "/admin";
						} else {
							alert("저장되었습니다.")
							document.location.reload();
						}
				    }
				});
			}
		}	
	}

	</script>
</head>
<body>
<div id="wrap">
		<div id="popup">
			<div class="menu_title">
				<h1>고객상담이력</h1>
				<div class="r mt2">
			<%	if (isAdmin) { %>
					<a href="#nohref" onclick="fnSave()"><img src="../images/btn_save.gif" /></a>
					<a href="./counselInfo.jsp?counsel_id=<%=counsel_id%>"><img src="../images/btn_cancel.gif" /></a>
			<%	} %>
					<input type="image" class="button" src="../images/btn_close.gif" onclick="self.close()"/>
				</div>
			</div>
			<div class="clear line_01"></div>
		
			<h3>고객정보</h3>
			<table cellpadding="0" cellspacing="0" class="table_01 mt5">
			<colgroup>
				<col width="80px"/>
				<col/>
				<col width="80px"/>
				<col/>
				<col width="80px"/>
				<col/>
			</colgroup>
			<tbody>
				<tr>
					<th><p>이름</p></th>
					<td>
						<%= info.get("customer_name", 0) %>
					</td>
					<th><p>생년월일</p></th>
					<td>
						<%= info.get("birth_date", 0) %>
					</td>
					<th><p>성별</p></th>
					<td>
						<%= info.get("gender_name", 0) %>
					</td>
				</tr>
				<tr>
					<th><p>세대구분</p></th>
					<td>
						<%= info.get("family_gubn_name", 0) %>
					</td>
					<th><p>가구원수</p></th>
					<td>
						<%= info.get("family_count", 0) %>
					</td>
					<th><p>보장구분</p></th>
					<td>
						<%= info.get("support_gubn_name", 0) %>
					</td>
				</tr>
				<tr>
					<th><p>전화번호</p></th>
					<td>
						<%= info.get("tel_no", 0) %>
					</td>
					<th><p>핸드폰번호</p></th>
					<td>
						<%= info.get("hp_no", 0) %>
					</td>
					<th><p>수신동의</p></th>
					<td>
						<%= "Y".equals(info.get("tel_agree_yn", 0)) ? "전화(O)" : "전화(X)" %>, 
						<%= "Y".equals(info.get("sms_agree_yn", 0)) ? "SMS(O)" : "SMS(X)" %>
					</td>
				</tr>
				<tr>
					<th><p>행정동</p></th>
					<td>
						<%= info.get("dong_name", 0) %>
					</td>
					<th><p>주소</p></th>
					<td colspan="3">
						<%= info.getToBr("address", 0) %>
					</td>
				</tr>
				<tr>
					<th><p>비고</p></th>
					<td colspan="5">
						<%= info.getToBr("remarks", 0) %>
					</td>
				</tr>
			</tbody>
			</table>
			
			
			<h3>상담정보</h3>


			<form name="saveForm" id="saveForm" method="post" action="">
			<input type="hidden" name="job_type" id="job_type" value="U"/>
			<input type="hidden" name="counsel_id" value="<%= info.get("counsel_id", 0) %>"/>
			
			<table cellpadding="0" cellspacing="0" class="table_01 mt5">
			<colgroup>
				<col width="80px"/>
				<col/>
				<col width="80px"/>
				<col/>
				<col width="80px"/>
				<col/>
			</colgroup>
			<tbody>
				<tr>
					<th><p>상담경로</p></th>
					<td>
						<select name="counsel_path" class="w120">
						<%= StringUtil.makeOption(code300, info.get("counsel_path", 0)) %>
						</select>
					</td>
					<th><p>상담일자</p></th>
					<td>
						<input type="text" class="text w80 c" name="counsel_date" id="counsel_date" value="<%= info.get("counsel_date", 0) %>" />
					</td>
					<th><p>상담유형</p></th>
					<td>
						<%= StringUtil.makeRadio(code301, "counsel_type", info.get("counsel_type", 0)) %>
					</td>
				</tr>
				<tr>
					<th><p>분류(a)</p></th>
					<td>
						<select name="counsel_kind1" class="w60 counsel_kind">
						<%= StringUtil.makeOption(code305, info.get("counsel_kind1", 0)) %>
						</select>
						<select name="counsel_part1" class="w100 counsel_part">
						</select>
					</td>
					<th><p>분류(b)</p></th>
					<td>
						<select name="counsel_kind2" class="w60 counsel_kind">
						<option value=""></option>
						<%= StringUtil.makeOption(code305, info.get("counsel_kind2", 0)) %>
						</select>
						<select name="counsel_part2" class="w100 counsel_part">
						</select>
					</td>
					<th><p>분류(c)</p></th>
					<td> 
						<select name="counsel_kind3" class="w60 counsel_kind">
						<option value=""></option>
						<%= StringUtil.makeOption(code305, info.get("counsel_kind3", 0)) %>
						</select>
						<select name="counsel_part3" class="w100 counsel_part">
						</select>
					</td>
				</tr>
				<tr>
					<th><p>서비스명</p></th>
					<td colspan="5">
						<input type="text" class="text wmax" name="service_name" value="<%= info.get("service_name", 0) %>" />
					</td>
				</tr>
				<tr>
					<th><p>상담질문</p></th>
					<td colspan="5">
						<textarea name="question" rows="4" class="wmax"><%= info.get("question", 0) %></textarea>
					</td>
				</tr>
				<tr>
					<th><p>상담답변</p></th>
					<td colspan="5">
						<textarea name="answer" rows="4" class="wmax"><%= info.get("answer", 0) %></textarea>
					</td>
				</tr>
				<tr>
					<th><p>특이사항</p></th>
					<td colspan="5">
						<textarea name="note" rows="3" class="wmax"><%= info.get("note", 0) %></textarea>
					</td>
				</tr>
				<tr>
					<th><p>알림요청</p></th>
					<td>
						<%= StringUtil.makeRadio(code309, "alarm_code", info.get("alarm_code", 0)) %>
					</td>
					<th><p>상담결과</p></th>
					<td colspan="3">
						<%= StringUtil.makeRadio(code302, "counsel_result", info.get("counsel_result", 0)) %>
					</td>
				</tr>
			</tbody>
			</table>
			</form>
			
		</div>
		
</div>



</body>
</html>
